<template>
	<div>
		<el-form ref="queryForm" :inline="true">
			<el-form-item label="题目类型：" style="width: 300px;">
				<el-select placeholder="题目类型" v-model="questionType">
					<el-option v-for="item in questionEnum" :key="item.id" :value="item.id" :label="item.qtype">
					</el-option>
				</el-select>
			</el-form-item>
			<el-form-item>
				<el-button type="primary" @click="submitForm">查询</el-button>
				<el-popover placement="bottom" trigger="click">
				  <el-button type="warning" size="mini" v-for="item in questionEnum" :key="item.id"
				             @click="$router.push({ path:item.url})">{{item.qtype}}
				  </el-button>
				  <el-button slot="reference" type="success" class="link-left">添加</el-button>
				</el-popover>
			</el-form-item>
			</el-form>
			<el-table v-loading="loading" :data="tableData" border fit highlight-current-row style="width: 70%;margin: auto;">
			  
			  <el-table-column prop="questionType" label="题型" width="70px" align="center"/>
			  <el-table-column prop="shortTitle" label="题干" show-overflow-tooltip align="center"/>
			  <el-table-column prop="createTime" label="创建时间" width="160px" align="center"/>
			  <el-table-column label="操作" align="center" width="220px" >
			    <template slot-scope="{row}">
			      <el-button size="mini"  @click="editQuestion(row)">编辑</el-button>
			      <el-button size="mini"  type="danger" @click="deleteQuestion(row)" class="link-left">删除</el-button>
			    </template>
			  </el-table-column>
			</el-table>
			
			
			
	</div>
</template>

<script>
	export default {
		data() {
			return {
				tableData:[
					{
						id:'1',
						questionType:'单选题',
						shortTitle:'前门',
						score:'5',
						createTime:'2020/2/10'
					},
					{
						id:'2',
						questionType:'多选题',
						shortTitle:'前门24552',
						score:'5',
						createTime:'2020/2/10'
					},
					{
						id:'3',
						questionType:'简答题',
						shortTitle:'后门口',
						score:'5',
						createTime:'2020/2/10'
					}
				],
				loading:false,
				showAddOptionForm: false,
				questionType: '',
				questionEnum: [{
						id: '1',
						qtype: '单选题',
						url:'/question/add/single'
					},
					{
						id: '2',
						qtype: '多选题',
						url:'/question/add/multiply'
					},
					{
						id: '3',
						qtype: '简答题',
						url:'/question/add/short'
					}
				],
			}
		},
		created() {
			console.log("4545454545")
		},
		methods: {
			submitForm() {},
			deleteQuestion(row){
				let flag=-1;
				for (let item in this.$data.tableData) {
					flag++;
					if(this.$data.tableData[item].id==row.id){
						break;
					}
				}
				this.$data.tableData.splice(flag,1);
			},
			
			editQuestion(row){
				if(row.questionType=="单选题"){
					this.$router.push({path:'/question/add/single',query:{id:row.id}})
				}
				if(row.questionType=="多选题"){
					this.$router.push({path:'/question/add/multiply',query:{id:row.id}})
				}
				if(row.questionType=="简答题"){
					this.$router.push({path:'/question/add/short',query:{id:row.id}})
				}
				
				
				
			}
		}



	}
</script>

<style>
</style>
